<template>
  <ul class="rightList-container">
    <li v-for="(item, i) in list" :key="i">
      <span @click="handleClick(item)" :class="{ active: item.isSelect }">{{
        item.name
      }}</span>
      <span class="aside" 
      v-if="item.aside" 
      :class="{ active: item.isSelect }"
      @click="handleClick(item)"
      >{{item.aside}}
      </span>
      <RightList :list="item.children" @select="handleClick" />
    </li>
  </ul>
</template>

<script>
export default {
  name: "RightList", // name 组件名称缺失的时候使用name当组件名称
  methods: {
    handleClick(item) {
      if (!item.select) {
        this.$emit("select", item);
      }
    },
  },
  props: {
    list: {
      type: Array, // 类型为数组类型
      default: () => [], // 返回一个函数 默认空数组
    },
  },
};
</script>

<style lang="less" scoped>
@import url("~@/style/var.less");
.rightList-container {
  list-style: none;
  padding: 0;
  .rightList-container {
    margin-left: 1em;
  }
  li {
    min-height: 40px;
    line-height: 40px;
    cursor: pointer;
    font-size: 14px;
    .active {
      color: @warn;
      font-weight: bold;
    }
  }
  .aside{
    font-size: 14px;
    color: @gray;
    margin-left: 1em;
  }
}
</style>